import {axios} from "../utils/request";
import global from "../store/global";

const api = global.serverAddress + "/user";


export function registerAPI(registerData) {
    return axios({
        url: `${api}/register`,
        method: "POST",
        data: registerData,
    });
}

export function findPasswordAPI(data) {
    return axios({
        url: `${api}/find_password`,
        method: "POST",
        data: data,
    });
}

export function getUserInfoAPI(userId) {
    return axios({
        url: `${api}/get_user_info/${userId}`,
        method: "GET",
    });
}

export function sendMailCodeAPI(data) {
    return axios({
        url: `${api}/send_mail_code/?mail=${data.mail}`,
        method: "POST",
    });
}

export function sendMailCodeLAPI(data) {
    return axios({
        url: `${api}/send_mail_code/1?mail=${data.mail}`,
        method: "POST",
    });
}

export function updatePasswordAPI(data) {
    return axios({
        url: `${api}/update_password/${data.id}?newPassword=${data.newPassword}&oldPassword=${data.oldPassword}`,
        method: "POST",
    });
}